/**
 * StringSplit.cpp
 *
 * Version: $Id: StringSplit.cpp 72 2011-12-10 12:07:13Z s8376@pjwstk.edu.pl $
 */
#include <cstring>
#include "StringSplit.h"

using namespace std;

StringSplit::~StringSplit()
{
    delete[] m_string;
    m_string = 0;
}
char* StringSplit::show()
{
    return m_string;
}
void StringSplit::splitString(char* s)
{
    int mLen = strlen(m_string);
    int sLen = strlen(s);
    int newStringLenght = mLen + sLen;
    int half = mLen / 2;

    char* newString = new char[newStringLenght + 1];

    for (int i = 0; i < newStringLenght; i++) {
        if (i < half) {
            newString[i] = m_string[i];
        } else if (i < half + sLen) {
            newString[i] = s[i - half];
        } else {
            newString[i] = m_string[i - half - sLen];
        }
    }

    newString[newStringLenght] = 0;
    delete[] m_string;
    m_string = newString;
}
